package com.linkgie.galaxyframework.crypto;

import java.io.Serializable;

/**
 * 密钥对；
 * 
 * @author liso
 *
 */
public final class CryptoKeypair implements Serializable {

	private static final long serialVersionUID = -6126550539485165401L;

	private PublicKey pubKey;

	private PrivateKey privKey;
	
	public CryptoKeypair(PublicKey pubKey, PrivateKey privKey) {
		if (!pubKey.getAlgorithm().equals(privKey.getAlgorithm())) {
			throw new IllegalArgumentException("The Public Key and Private Key are not the same algorithm!");
		}
		this.pubKey = pubKey;
		this.privKey = privKey;
	}

	/**
	 * 密码算法；
	 * 
	 * @return
	 */
	public Algorithm getAlgorithm() {
		return pubKey.getAlgorithm();
	}

	/**
	 * 公钥；
	 * 
	 * @return
	 */
	public PublicKey getPublic() {
		return pubKey;
	}

	/**
	 * 私钥；
	 * 
	 * @return
	 */
	public PrivateKey getPrivate() {
		return privKey;
	}

}
